package com.joker.demo.core.constant;

/**
 * 任务调度常量类
 */
public class JobConstants {
    
    /**
     * 任务状态
     */
    public static final int JOB_STATUS_STOP = 0;    // 停止
    public static final int JOB_STATUS_RUN = 1;     // 运行
    
    /**
     * 调度类型
     */
    public static final String SCHEDULE_TYPE_CRON = "CRON";           // CRON表达式
    public static final String SCHEDULE_TYPE_FIX_RATE = "FIX_RATE";   // 固定频率
    public static final String SCHEDULE_TYPE_FIX_DELAY = "FIX_DELAY"; // 固定延迟
    
    /**
     * 调度过期策略
     */
    public static final String MISFIRE_STRATEGY_IGNORE = "IGNORE";     // 忽略
    public static final String MISFIRE_STRATEGY_FIRE_ONCE = "FIRE_ONCE"; // 立即补偿
    
    /**
     * 路由策略
     */
    public static final String ROUTE_STRATEGY_FIRST = "FIRST";         // 第一个
    public static final String ROUTE_STRATEGY_LAST = "LAST";           // 最后一个
    public static final String ROUTE_STRATEGY_ROUND = "ROUND";         // 轮询
    public static final String ROUTE_STRATEGY_RANDOM = "RANDOM";       // 随机
    public static final String ROUTE_STRATEGY_CONSISTENT_HASH = "CONSISTENT_HASH"; // 一致性HASH
    public static final String ROUTE_STRATEGY_LFU = "LFU";             // 最不经常使用
    public static final String ROUTE_STRATEGY_LRU = "LRU";             // 最近最久未使用
    public static final String ROUTE_STRATEGY_FAILOVER = "FAILOVER";   // 故障转移
    public static final String ROUTE_STRATEGY_BUSYOVER = "BUSYOVER";   // 忙碌转移
    
    /**
     * 阻塞处理策略
     */
    public static final String BLOCK_STRATEGY_SERIAL = "SERIAL";       // 单机串行
    public static final String BLOCK_STRATEGY_DISCARD = "DISCARD";     // 丢弃后续
    public static final String BLOCK_STRATEGY_COVER = "COVER";         // 覆盖之前
    
    /**
     * 执行状态
     */
    public static final int HANDLE_CODE_SUCCESS = 200;     // 成功
    public static final int HANDLE_CODE_FAIL = 500;        // 失败
    public static final int HANDLE_CODE_TIMEOUT = 502;     // 超时
    
    /**
     * 触发结果
     */
    public static final int TRIGGER_CODE_SUCCESS = 200;    // 成功
    public static final int TRIGGER_CODE_FAIL = 500;       // 失败
    
    /**
     * 告警状态
     */
    public static final int ALARM_STATUS_DEFAULT = 0;      // 默认
    public static final int ALARM_STATUS_NO_NEED = 1;      // 无需告警
    public static final int ALARM_STATUS_SUCCESS = 2;      // 告警成功
    public static final int ALARM_STATUS_FAIL = 3;         // 告警失败
    
    /**
     * 分片状态
     */
    public static final int SHARDING_STATUS_PENDING = 0;   // 未执行
    public static final int SHARDING_STATUS_RUNNING = 1;   // 执行中
    public static final int SHARDING_STATUS_SUCCESS = 2;   // 执行成功
    public static final int SHARDING_STATUS_FAIL = 3;      // 执行失败
    
    /**
     * 地址类型
     */
    public static final int ADDRESS_TYPE_AUTO = 0;         // 自动注册
    public static final int ADDRESS_TYPE_MANUAL = 1;       // 手动录入
    
    /**
     * 注册组
     */
    public static final String REGISTRY_GROUP_EXECUTOR = "executor";   // 执行器
    public static final String REGISTRY_GROUP_ADMIN = "admin";         // 调度中心
    
    /**
     * 默认值
     */
    public static final int DEFAULT_RETRY_COUNT = 0;       // 默认重试次数
    public static final int DEFAULT_TIMEOUT = 0;           // 默认超时时间
    public static final int DEFAULT_JOB_GROUP = 1;         // 默认执行器组


    public static final String EXECUTE_TASK_URL = "/executeTask";
    public static final String CANCEL_TASK_URL = "/cancelTask";
} 